//
//  UserGuideViewController.m
//  ZYZB
//
//  Created by ENERGY on 2018/7/31.
//  Copyright © 2018年 ENERGY. All rights reserved.
//

#import "UserGuideViewController.h"
#import "MainViewController.h"
@interface UserGuideViewController ()
@property (nonatomic, strong)UIScrollView * scrollView;
@end

@implementation UserGuideViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    [self initGuide];   //加载新用户指导页面
}
- (void)initGuide
{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [scrollView setContentSize:CGSizeMake(SCREEN_WIDTH * 3, 0)];
    [scrollView setPagingEnabled:YES];  //视图整页显示
    scrollView.bounces = NO;
    self.scrollView = scrollView;
    //    [scrollView setBounces:NO]; //避免弹跳效果,避免把根视图露出来
    
    UIImageView *imageview = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [imageview setImage:[UIImage imageNamed:@"4.png"]];
    [scrollView addSubview:imageview];
    int btnX = 97/WIDTH_6_SCALE;
    int btnH = 65/WIDTH_6_SCALE;
    UIButton * imageButton = [[UIButton alloc] initWithFrame:CGRectMake(97/WIDTH_6_SCALE, SCREEN_HEIGHT - 158/WIDTH_6_SCALE - btnH, SCREEN_WIDTH - 2*btnX , btnH)];
    imageButton.backgroundColor = [UIColor redColor];
    [imageButton addTarget:self action:@selector(imageButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:imageButton];
    
    UIImageView *imageview1 = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [imageview1 setImage:[UIImage imageNamed:@"5.png"]];
    [scrollView addSubview:imageview1];
    UIButton * imageButton1 = [[UIButton alloc] initWithFrame:CGRectMake(97/WIDTH_6_SCALE + SCREEN_WIDTH, SCREEN_HEIGHT - 158/WIDTH_6_SCALE - btnH, SCREEN_WIDTH - 2*btnX , btnH)];
    imageButton1.backgroundColor = [UIColor redColor];
    [imageButton1 addTarget:self action:@selector(imageButtonClick1:) forControlEvents:UIControlEventTouchUpInside];
    [scrollView addSubview:imageButton1];
    
    UIImageView *imageview2 = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH * 2, 0, SCREEN_WIDTH, SCREEN_HEIGHT)];
    [imageview2 setImage:[UIImage imageNamed:@"6.png"]];
    imageview2.userInteractionEnabled = YES;//打开imageview2的用户交互;否则下面的button无法响应
    [scrollView addSubview:imageview2];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//在imageview3上加载一个透明的button
    [button setTitle:nil forState:UIControlStateNormal];
    [button setFrame:CGRectMake(97/WIDTH_6_SCALE + SCREEN_WIDTH * 2, SCREEN_HEIGHT - 158/WIDTH_6_SCALE - btnH, SCREEN_WIDTH - 2*btnX , btnH)];
    [button addTarget:self action:@selector(firstpressed) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor redColor];
    [scrollView addSubview:button];
    
    [self.view addSubview:scrollView];
}
#pragma mark - action
- (void)firstpressed{
    MainViewController * mainVC = [[MainViewController alloc] init];
    [self presentModalViewController:mainVC animated:YES];//点击button跳转到根视图
}
- (void)imageButtonClick:(UIButton *)sender{
    [self.scrollView setContentOffset:CGPointMake(SCREEN_WIDTH,0) animated:YES];
}
- (void)imageButtonClick1:(UIButton *)sender{
    [self.scrollView setContentOffset:CGPointMake(SCREEN_WIDTH * 2,0) animated:YES];
}
@end
